<?php

/**
 * This is the model class for table "{{model_api}}".
 *
 * The followings are the available columns in table '{{model_api}}':
 * @property integer $zd_model_api_id
 * @property string $model_name
 * @property string $model_api_name
 * @property string $api_method
 * @property string $description
 */
class ModelApi extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ModelApi the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{model_api}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('model_name', 'length', 'max'=>100),
			array('model_api_name, api_method', 'length', 'max'=>255),		
			array('description', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zd_model_api_id, model_name, model_api_name, api_method, description', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zd_model_api_id' => 'ID',
			'model_name' => '模型名称',
			'model_api_name' => '接口名称',
			'api_method' => '接口方法',
			'description' => '说明',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zd_model_api_id',$this->zd_model_api_id);
		$criteria->compare('model_name',$this->model_name,true);
		$criteria->compare('model_api_name',$this->model_api_name,true);
		$criteria->compare('api_method',$this->api_method,true);
		$criteria->compare('description',$this->description,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}